package com.yeheng.myvalidator;

import com.yeheng.Myannotion.MyParam;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @PackgeName: com.yeheng.myvalidator
 * @ClassName: MyValidator
 * @Author: YH
 * Date: 2020/12/30 16:51
 * project name: springmvc_Validation
 * @Version:
 * @Description:
 */
public class MyValidator implements ConstraintValidator<MyParam,Integer> {
    private int min;
    private int max;
    @Override
    public void initialize(MyParam constraintAnnotation) {
        this.min = constraintAnnotation.min();
        this.max = constraintAnnotation.max();
    }

    @Override
    public boolean isValid(Integer integer, ConstraintValidatorContext constraintValidatorContext) {
        if (integer>min&&integer<max){

            return true;
        }
        return false;

    }
}
